/** Author: David Powell
This file produces Figure 1 + Figure A2	
**/

clear all
set more off
set mat 11000
set seed 8721


global dir "/jules/b/dpowell"
global DATA "${dir}/purdue/replication/DATA"
global OUTPUT "${dir}/purdue/replication/output"


use ${DATA}/finaldata

gen overdose_rate=100000*(overdose/totpop)
gen opioid_rate=100000*opioids/totpop


gcollapse *_rate [pw=totpop], by(year) fast

set scheme s2mono



# delimit ;


twoway (connected opioid_rate year if year>1982, color(black) lpattern(dash) lwidth(thick) msize(vtiny) sort yaxis(1))   
(connected overdose_rate year if year>1982, color(red) lwidth(thick) msize(vtiny) sort yaxis(1)) 
, graphregion(color(white))   xlabel(1983(2)2017, angle(45)) legend(off) xtitle("Year") ytitle("Deaths per 100,000") 
text(17 2005.6 "All Drug Overdoses", place(e))
text(5.5 2009.4 "Opioid Overdoses", place(e))
ylabel(, nogrid angle(horizontal))
scheme(s2mono);
gr export ${OUTPUT}/fig1.eps, replace;


twoway (connected overdose_rate year if year>1995 & year<2004, color(black) msize(small) sort yaxis(1))   
, graphregion(color(white))  xline(1999) ylabel(,nogrid) xlabel(1996(1)2003, angle(45))  legend(label(2 "Overdoses") label(1 "Opioid Overdoses")  rows(1) order(2 1)) xtitle("Year") ytitle("Deaths per 100,000" ,  axis(1)) ;
gr export ${OUTPUT}/figA2a.eps, replace;


twoway (connected opioid_rate year if year>1995 & year<2004, color(black) msize(small) sort yaxis(1))   
, graphregion(color(white))  xline(1999) ylabel(,nogrid) xlabel(1996(1)2003, angle(45))  legend(label(2 "Overdoses") label(1 "Opioid Overdoses")  rows(1) order(2 1)) xtitle("Year") ytitle("Deaths per 100,000" ,  axis(1));
gr export ${OUTPUT}/figA2b.eps, replace;



